package com.news.news.util;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Created by 罗铠威 on 2023/8/30 11:44
 * type:统一处理异常（AOP--通知）
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 异常处理
     */
    @ExceptionHandler(Exception.class)
    public CommonResult globalException(Exception e) {
        e.printStackTrace();
        CommonResult commonResult = new CommonResult(500,null,e.getMessage());
        return commonResult;
    }
}
